package io;

import java.io.Serializable;
import java.util.Arrays;
import java.util.Objects;

public class Student implements Serializable {//implements Serializable  实现序列化列表
    private String name ;
    private int age ;
    private  String gender;
    private transient String[]  otherInfo;
/**
 * 当一个属性被关键字transient 修饰后，当这个对象进行序列化时，此属性值会被忽略
 * 忽略不必要的属性值可以达到对象序到化瘦身的目的,
 * 可以减少磁盘开销或提高网络传输效率
 */
    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", gender='" + gender + '\'' +
                ", otherInfo=" + Arrays.toString(otherInfo) +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Student student = (Student) o;
        return age == student.age && Objects.equals(name, student.name) && Objects.equals(gender, student.gender) && Arrays.equals(otherInfo, student.otherInfo);
    }

    @Override
    public int hashCode() {
        int result = Objects.hash(name, age, gender);
        result = 31 * result + Arrays.hashCode(otherInfo);
        return result;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public String[] getOtherInfo() {
        return otherInfo;
    }

    public void setOtherInfo(String[] otherInfo) {
        this.otherInfo = otherInfo;
    }

    public Student(String name, int age, String gender, String[] otherInfo) {
        this.name = name;
        this.age = age;
        this.gender = gender;
        this.otherInfo = otherInfo;
    }

    public Student() {
    }

}
